package com.xiao.sulinguser.controller;

import com.xiao.sulingpublic.utils.PageUtils;
import com.xiao.sulingpublic.utils.R;
import com.xiao.sulinguser.entity.MemberTypeEntity;
import com.xiao.sulinguser.service.MemberTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;





/**
 * 用户类型表
 *
 * @author wen
 * @email 1322127758@qq.com
 * @date 2022-03-11 15:01:06
 */
@RestController
@RequestMapping("sulinguxqg/membertype")
public class MemberTypeController {
    @Autowired
    private MemberTypeService memberTypeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("sulinguxqg:membertype:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = memberTypeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{memberTypeId}")
    //@RequiresPermissions("sulinguxqg:membertype:info")
    public R info(@PathVariable("memberTypeId") Long memberTypeId){
		MemberTypeEntity memberType = memberTypeService.getById(memberTypeId);

        return R.ok().put("memberType", memberType);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("sulinguxqg:membertype:save")
    public R save(@RequestBody MemberTypeEntity memberType){
		memberTypeService.save(memberType);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("sulinguxqg:membertype:update")
    public R update(@RequestBody MemberTypeEntity memberType){
		memberTypeService.updateById(memberType);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("sulinguxqg:membertype:delete")
    public R delete(@RequestBody Long[] memberTypeIds){
		memberTypeService.removeByIds(Arrays.asList(memberTypeIds));

        return R.ok();
    }

}
